//
//  MeRegisterLoginVC.m
//  ZITHER
//
//  Created by weixin on 2019/1/16.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "MeRegisterLoginVC.h"
#import "MeRegisterLoginInputFieldView.h"
#import "MeRegisterVC.h"
#import "MeRegisterRegisterVC.h"

@interface MeRegisterLoginVC ()

@property (nonatomic,strong)MeRegisterLoginInputFieldView * inputView;

@property (nonatomic,strong)BaseBtn * phonebtn;

@end

@implementation MeRegisterLoginVC

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self setNav];
    
    [self setUI];

}

-(void)setNav{
    [self.baseNavigationView NavigationBarStyle:1];
    self.baseNavigationView.leftButton1.hidden = YES;
    self.baseNavigationView.isShowShadow = NO;
    self.baseNavigationView.navViewStyle.title.text = @"登录";
    self.baseNavigationView.navViewStyle.rightBtn.hidden = NO;
    self.baseNavigationView.navViewStyle.clipsToBounds=  NO;
    
    [self.baseNavigationView.navViewStyle.rightBtn setTitle:@"注册" forState:UIControlStateNormal];
    [self.baseNavigationView.navViewStyle.rightBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
        [self.baseNavigationView.navViewStyle.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
    }else{
        [self.baseNavigationView.navViewStyle.rightBtn setTitleColor:baseColorTheme forState:UIControlStateNormal];
    }
   

    self.baseNavigationView.navViewStyle.rightBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
    

    
    CGRect f =self.baseNavigationView.navViewStyle.rightBtn.frame;
    f.size.width = 50;
    f.size.height = 30;
    f.origin.y = f.origin.y-10;
    f.origin.x = f.origin.x-35;
    self.baseNavigationView.navViewStyle.rightBtn.frame =f;
    self.baseNavigationView.navViewStyle.rightBtn.centerY = self.baseNavigationView.navViewStyle.centerY+centerYH;
    
    @weakify(self);
    [[self.baseNavigationView.navViewStyle.rightBtn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            MeRegisterRegisterVC * vc = [[MeRegisterRegisterVC alloc]init];
            vc.state = MeRegisterRegisterStateRegister;
            [self.navigationController pushViewController:vc animated:YES];
    }];
    
    self.baseNavigationView.navViewStyle.isShowShadow = NO;
    self.baseNavigationView.bottomLineView.hidden = YES;
}

-(void)setUI{
    [self.view addSubview:self.inputView];
    [self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(NaviHeight);
        make.height.mas_equalTo(400);
    }];
    
    self.phonebtn = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0, 0, 0) NormalImage:@"登录_短信验证" SeleImage:@""];
    self.phonebtn.backgroundColor = [UIColor clearColor];
    [self.view addSubview: self.phonebtn];
    [self.phonebtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX).offset(0);
        make.bottom.equalTo(self.view).offset(-30);
        make.height.width.mas_equalTo(30);
    }];
    
    @weakify(self);
    [[self.phonebtn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        
        MeRegisterVC *vc = [[MeRegisterVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];

    }];
    
    
    BaseLab *lab = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, 0, 0) text:@"短信快捷登录" font:12 textColor:HexColor(0x999999) isBold:NO numberOfLines:0];
    [self.view addSubview:lab];
    lab.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX).offset(0);
        make.height.mas_equalTo(14);
        make.bottom.equalTo(self.view.mas_bottom).offset(-75);
    }];
    
    
    
    for (int i = 0 ; i<2; i++) {
        BaseView *view = [[BaseView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        view.backgroundColor = HexColor(0xeeeeee);
        
        [self.view addSubview:view];
        
        if (i == 0 ) {
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.view).offset(-15);
                make.left.equalTo(lab.mas_right).offset(37);
                make.centerY.equalTo(lab.mas_centerY).offset(0);
                make.height.mas_equalTo(1);
            }];
        }else{
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.view).offset(-15);
                make.centerY.equalTo(lab.mas_centerY).offset(0);
                make.height.mas_equalTo(1);
                make.right.equalTo(lab.mas_left).offset(-37);
            }];
            
        }
    }
}

-(MeRegisterLoginInputFieldView *)inputView{
    if (!_inputView) {
        _inputView = [[MeRegisterLoginInputFieldView alloc]initWithFrame:CGRectMake(0, 400, kScreenW, kScreenH)];
    }
    return _inputView;
}

@end
